home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir42 / dbind2.zip / DBINDENT.DOC < prev    next >
Text File  |  1993-10-16  |  5KB  |  94 lines

  1. Looking for a way to make your program listings easier to read?  Ever think
  2. you'd go crazy trying to find mismatched IF...ENDIFs or figuring which ENDDO
  3. goes with which DO WHILE?  DBINDENT.PRG is a dBaseIII+ program which evolved
  4. over a period of time to make such tasks much easier.
  5.  
  6. You'll need a .DBF file named DBINDENT consisting of 1 character type field
  7. named ENT.  My DBINDENT.DBF has a field width of 120 so the ends of deeply
  8. indented lines won't get lost; you can make it any size you like up to 254.
  9. Sure, going over 80 makes lines extend past the right edge of the screen on
  10. most monitors when you view the data but I use an editor that lets me get to
  11. that data, too.  (Try QEdit v2.15, a shareware package from SemWare available
  12. on CompuServ; for the power it has it's a fantastic buy.  I use it in place
  13. of 'real' word processors so much I've forgotten my WordPerfect commands.)
  14.  
  15. The program is pretty straightforward in the way it's used.  I always clear
  16. anything left over in DBINDENT.DBF and set it up as follows:
  17.  
  18.        USE DBINDENT
  19.        ZAP
  20.        CLEAR ALL
  21.        APPEND FROM <file spec> SDF
  22.  
  23. Unless the file being appended is in your dBase default directory, a path must
  24. be included as part of <file spec>.  If the file name extension for the file
  25. being 'absorbed' is anything except .DBF, include it in <file spec>, too.  And
  26. unless the file is a true dBase (or compatible xBase) file, be sure to include
  27. the SDF file type indicator at the end of the APPEND FROM command.
  28.  
  29. At this point you simply enter the command DO DBINDENT at the dBase prompt.
  30.  
  31. DBINDENT.PRG first trims empty space from the left end of each line, then
  32. looks for the following commands to indent or de-indent as appropriate:
  33. (DBINDENT looks for these commands in both their long or short forms.)
  34.         DO WHILE         ENDDO
  35.         IF               ENDIF       ELSE
  36.         DO CASE          ENDCASE     OTHERWISE
  37.         PROCEDURE        RETURN      PARAMETERS
  38.  
  39. It 'temporarily de-indents' ELSE, OTHERWISE and PARAMETERS statements so
  40. they're even with IF, DO CASE AND PRODCURE lines for easier reading and all
  41. are capitalized unless a TEXT command is found; TEXT...ENDTEXT lines are not
  42. affected at all.  And in the case of @ SAY...GET lines, upper/lower case is
  43. not affected plus you have the option of setting the line even with the left
  44. margin.  Comment lines can be indented, left flush at the left end of the line
  45. or deleted according to your preference with minor changes.  It's also easy
  46. to disable the capitalizing of lines other than @ SAY...GETs and TEXT.
  47.  
  48. When you're all done, the command
  49.        COPY TO <file spec> DELI WITH BLANKS
  50.                             will give you an ASCII type listing.  It's not
  51. necessary for the <file spec> in the COPY TO command be the same as in the
  52. APPEND FROM command.  As a matter of fact, it might be wise to use a similar
  53. but different name until you test the indented program.
  54.  
  55. I use DBINDENT quite often with good results and, while it takes a little time
  56. to process listing with a large number of lines, it been worth the time as a
  57. debugging tool.  Besides, it leaves you with a listing you're not ashamed to
  58. show to your boss without spending hours indenting with an editor, too.  Let
  59. him (or her as the case may be) think you spent all night slaving in front of
  60. your monitor instead of lounging in front of the TV anyway; maybe you'll get
  61. that raise you deserve.
  62.  
  63. (Another hint:  If you use && to add comments to the ends of command lines and
  64. tried to remove them you've probably found that && in a command, even if you
  65. enclose it in quotes, truncates everything to the right in the command itself
  66. so it doesn't work.  You can remove these comments and leave the rest of the
  67. line intact with the following command while using DBINDENT:
  68.     REPLACE LINE WITH LEFT(LINE, AT(("&"+"&"), ENT) -1) FOR ("&"+"&") $ LINE
  69.  
  70. A companion program with also uses DBINDENT.DBF is CHKLOOPS.PRG.  This program
  71. deletes everything in the file, then recalls selected commands, (IF, ENDIF, DO
  72. WHILE, ENDDO, etc) and provides a count for each.  If the counts don't match,
  73. you can copy the results to a separate file so search out the mismatched
  74. command.  (I'm forever ending DO WHILEs with ENDIFs.)  There are two reasons
  75. CHKLOOPS should be used AFTER running DBINDENT.  First, running DBINDENT
  76. before CHKLOOPS makes it easier to find errors and secondly, CHKLOOPS does NOT
  77. recall all the original statements when it's done running.
  78.  
  79. So there you are.  Good luck and good hunting.  I hope you find that DBINDENT
  80. and/or CHKLOOPS are as useful to you as they have been for me.
  81.  
  82. =============================================================================
  83.  
  84. My apologies to any of you who may have downloaded the 10Oct93 version of this
  85. file - I guess I let myself get too anxious about finally having something
  86. worth contributing and didn't bother to test some last minute changes I'd made
  87. in my attempt to clarify the program's internal documentation.  If you had
  88. trouble with DO CASE and/or DO WHILE indentations, they are taken care of in
  89. this revised version.  And, as before, comments are invited.
  90.  
  91. Thank you for your patience and thank you for giving me another chance.
  92.  
  93. Bob V, CompuServ 73230,2136
  94.